package com.base.andlang2.ui.dashboard

import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.alibaba.android.arouter.facade.annotation.Route
import com.base.andlang2.databinding.FragmentDashboardBinding
import com.base.andlangcore.mvvm.AndLangFragment
import com.base.andlangui.weight.ToastKt.toast
import com.base.andlangrouter.RouteUrl

@Route(path = RouteUrl.APP_HOME_TWO)
class DashboardFragment : AndLangFragment<FragmentDashboardBinding,DashboardViewModel>() {

    lateinit var textView: TextView
    override fun initView() {
        vb.apply {
            textView = textDashboard
        }
        vm.apply {
            data.observe(this@DashboardFragment, Observer {
                textView.text = it
            })
        }
    }

    override fun initData() {
        toast("接口请求...")
//        vm.reqHomeData()
        vm.reqApolloData()
    }

    override fun getVB(
        inflater: LayoutInflater,
        container: ViewGroup?
    ): FragmentDashboardBinding =FragmentDashboardBinding.inflate(inflater, container, false)

    override fun getVM(): DashboardViewModel = ViewModelProvider(this)[DashboardViewModel::class.java]
}